<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Kriging Library: likelihood_mod Module Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<script src="../mathjax/MathJax.js">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Kriging Library
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Data&#160;Types&#160;List</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Data&#160;Types</span></a></li>
      <li><a href="functions.html"><span>Data&#160;Fields</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">likelihood_mod Module Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="likelihood_mod" -->
<p><a href="modulelikelihood__mod-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">interface &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacelikelihood__mod_1_1likelihood.html">likelihood</a></td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">subroutine&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlikelihood__mod.html#ae115b05b90a40e98f7e5aea9753268b7">likelihood_func</a> (ndim, ntot, X, Y, stot, H, theta, sigma, sigmaN, logpy)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Subroutine for computing the likelihood formula for a function only Kriging model where noise level and covariance magnitude can be varied independently.  <a href="#ae115b05b90a40e98f7e5aea9753268b7"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">subroutine&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlikelihood__mod.html#a70ec9aa49f259289147455ee5b26880c">likelihood_grad</a> (ndim, ntot, X, Y, gtot, pts, dims, dY, stot, H, theta, sigma, sigmaN, sigmaNG, logpy)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Subroutine used for computing the likelihood formula for a gradient-enhanced Kriging model where funtion noise level, derivative noise level and covariance magnitude can be varied independently.  <a href="#a70ec9aa49f259289147455ee5b26880c"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock">
<p>Definition at line <a class="el" href="likelihood_8f90_source.html#l00012">12</a> of file <a class="el" href="likelihood_8f90_source.html">likelihood.f90</a>.</p>
</div><hr/><h2>Member Function/Subroutine Documentation</h2>
<a class="anchor" id="ae115b05b90a40e98f7e5aea9753268b7"></a><!-- doxytag: member="likelihood_mod::likelihood_func" ref="ae115b05b90a40e98f7e5aea9753268b7" args="(ndim, ntot, X, Y, stot, H, theta, sigma, sigmaN, logpy)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">subroutine likelihood_mod::likelihood_func </td>
          <td>(</td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ndim</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ntot</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim,ntot), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ntot), intent(in)&#160;</td>
          <td class="paramname"><em>Y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>stot</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(stot,ntot), intent(in)&#160;</td>
          <td class="paramname"><em>H</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>sigma</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>sigmaN</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(out)&#160;</td>
          <td class="paramname"><em>logpy</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Subroutine for computing the likelihood formula for a function only Kriging model where noise level and covariance magnitude can be varied independently. </p>
<p>The likelihood formula for a Gaussian process with a regression mean function is given by: </p>
<p class="formulaDsp">
\[ \log p(y | X; \theta) = -\frac{1}{2} Y^{T} K^{-1} (Y - H^{T} \beta) - \frac{1}{2} \log \vert K \vert - \frac{1}{2} \log \vert A \vert - \frac{N-S}{2} \log 2\pi \]
</p>
<p> where \(N\) is the number of training points (denoted by the argument <em>ntot</em>) and \(S\) is the number of terms in the regression (given by the argument <em>stot</em>). Here a vague prior on the regression parameters, \( \beta \) has been assumed (meaning that the distribution of these parameters is not known). The optimal regression parameters are given by: </p>
<p class="formulaDsp">
\[ \beta = A^{-1} H Y \]
</p>
<p> where the regression matrix \( A \) is defined as: </p>
<p class="formulaDsp">
\[ A = H K^{-1} H^{T} \]
</p>
<p>. Both the covariance matrix and regression matrix are symmetric positive definite, allowing cholesky to be performed on both matrices. This cholesky factorization is used to invert these matrices as well as compute the determinant. For a cholesky-factorized matrix (applicable for the regression and covariance matrix), the logarithm of the determinant is given as: </p>
<p class="formulaDsp">
\[ \log \vert C \vert = \log \vert L L^{T} \vert = 2 \sum_{k} L_{k,k} \]
</p>
<p> The subroutine below stores the inverse of the covariance in place. In the case that the cholesky of the inverse of the matrix is available, the determinant of the original matrix is found by applying a negative sign. </p>
<p class="formulaDsp">
\[ \log \vert C \vert = \log \vert (L^{-1} L^{-T})^{-1} \vert = - 2 \sum_{k} L^{-1}_{k,k} \]
</p>
<p> Further details of the likelihood formula used in this subroutine can be found in Chapter 2 of <a href="http://www.gaussianprocess.org/gpml/"><em> Gaussian Processes for Machine Learning </em> </a> by Rasmussen and Williams. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood Department of Mechanical Engineering University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 17, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> ndim </b>: The dimension of the problem </td></tr>
    <tr><td class="paramname">in)</td><td><b> ntot </b>: The number of training points </td></tr>
    <tr><td class="paramname">in)</td><td><b> X </b>: Location of the training points (size=[ndimxntot]) </td></tr>
    <tr><td class="paramname">in)</td><td><b>Y </b>: Funcation values for the training points (size=[ntot]) </td></tr>
    <tr><td class="paramname">in)</td><td><b>stot </b>: Number of Terms in the regression </td></tr>
    <tr><td class="paramname">in)</td><td><b>H</b>: The collocation matrix for the regression (size=[stotxntot]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> theta </b>: Length scale in each direction (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> sigma </b>: Covariance Magnitude </td></tr>
    <tr><td class="paramname">in)</td><td><b> sigmaN </b>: Noise Magnitude (added to diagonal of covariance matrix) </td></tr>
    <tr><td class="paramname">out)</td><td><b> logpy </b>: Natural Logarithm of the likelihood ( \( p(y | X,\theta, \sigma, \sigma_{N})\) </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="likelihood_8f90_source.html#l00052">52</a> of file <a class="el" href="likelihood_8f90_source.html">likelihood.f90</a>.</p>

</div>
</div>
<a class="anchor" id="a70ec9aa49f259289147455ee5b26880c"></a><!-- doxytag: member="likelihood_mod::likelihood_grad" ref="a70ec9aa49f259289147455ee5b26880c" args="(ndim, ntot, X, Y, gtot, pts, dims, dY, stot, H, theta, sigma, sigmaN, sigmaNG, logpy)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">subroutine likelihood_mod::likelihood_grad </td>
          <td>(</td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ndim</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ntot</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim,ntot), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ntot), intent(in)&#160;</td>
          <td class="paramname"><em>Y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>gtot</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, dimension(gtot), intent(in)&#160;</td>
          <td class="paramname"><em>pts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, dimension(gtot), intent(in)&#160;</td>
          <td class="paramname"><em>dims</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(gtot), intent(in)&#160;</td>
          <td class="paramname"><em>dY</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>stot</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(stot,ntot+gtot), intent(in)&#160;</td>
          <td class="paramname"><em>H</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>sigma</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>sigmaN</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>sigmaNG</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(out)&#160;</td>
          <td class="paramname"><em>logpy</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Subroutine used for computing the likelihood formula for a gradient-enhanced Kriging model where funtion noise level, derivative noise level and covariance magnitude can be varied independently. </p>

<p>Definition at line <a class="el" href="likelihood_8f90_source.html#l00127">127</a> of file <a class="el" href="likelihood_8f90_source.html">likelihood.f90</a>.</p>

</div>
</div>
<hr/>The documentation for this module was generated from the following file:<ul>
<li><a class="el" href="likelihood_8f90_source.html">likelihood.f90</a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>
Copyright (C) 2012 Brian A. Lockwood <br>
Generated on Tue May 1 2012 17:15:55 for Kriging Library
by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer"
							 src="doxygen.png"
							 alt="doxygen"/></a>
1.7.3
</small></address>
